package com.sl.biz.modular.office.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.sl.biz.modular.office.dao.domain.entity.OfficeRecordContentDO;
import com.sl.biz.modular.office.dao.service.OfficeRecordContentDaoService;
import com.sl.biz.modular.office.service.OfficeRecordContentBizService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class OfficeRecordContentBizServiceImpl implements OfficeRecordContentBizService {
    private final OfficeRecordContentDaoService officeRecordContentDaoService;

    @Override
    public Boolean save(OfficeRecordContentDO officeRecord) {

        String officeId = officeRecord.getOfficeId();
        OfficeRecordContentDO officeRecordContentDO = new OfficeRecordContentDO();
        officeRecordContentDO.setOfficeId(officeId);
        OfficeRecordContentDO byOfficeId = getByOfficeId(officeRecordContentDO);
        if (ObjectUtil.isNotNull(byOfficeId)) {
            officeRecord.setId(byOfficeId.getId());
        }
        return officeRecordContentDaoService.saveOrUpdate(officeRecord);
    }

    @Override
    public OfficeRecordContentDO getByOfficeId(OfficeRecordContentDO officeRecordDO) {
        return officeRecordContentDaoService.getByOfficeId(officeRecordDO.getOfficeId());

    }
}
